var currentName = '未定义';
function getData(num){
	$n = parseInt(num);
	var myArray = new Array();  
	for(i=0;i<=$n;i++){
		myArray[i] = i;
	}
	return "["+myArray.toString()+"]";
}

$(function(){
	$("#works .edit_select").editable('/updatePing.action',{
		indicator : '保存中',
        tooltip   : '单击编辑',
		type: 'select',
		name: "columnValue",
		data: function(){
			return getData($(this).attr("num"));
		},
		submitdata: function(){
        	$row = $(this).parent();
        	return {
        		columnName: $(this).attr("name"),
            	groupId: $row.parent().attr("id").substr(4)
        	};
        },
        callback: function(){
        	$row = $(this).parent();
        	$total = 0;
        	$(".ping", $row).each(function(){
        		$total += parseInt($(this).text());
        	});
        	$(".fen", $row).html($total);
        }
	});
	$("#works .edit_check").editable('/updatePing.action',{
		indicator : '保存中',
        tooltip   : '单击编辑',
		type: 'select',
		name: "columnValue",
		data: "{0:'否', 1:'是'}",
		submitdata: function(){
        	$row = $(this).parent();
        	return {
        		columnName: $(this).attr("name"),
            	groupId: $row.parent().attr("id").substr(4),
            	label: currentName
        	};
        }
	});
	$("#works .edit_input").editable('/updatePing.action',{
		indicator : '保存中',
        tooltip   : '单击编辑',
		name: "columnValue",
		submitdata: function(){
        	$row = $(this).parent();
        	return {
        		columnName: $(this).attr("name"),
            	groupId: $row.parent().attr("id").substr(4)
        	};
        }
	});
	$('select,input').live('change', function () {
		currentName = $("option:selected", $(this)).text();
        $(this).parent().submit();
    });
});